namespace Terra.Core.Configuration.Options
{
    /// <summary>
    /// 认证配置
    /// </summary>
    public class AuthSettings
    {
        /// <summary>
        /// JWT配置
        /// </summary>
        public JwtSettings Jwt { get; set; } = new();

        /// <summary>
        /// 密码配置
        /// </summary>
        public PasswordSettings Password { get; set; } = new();

        /// <summary>
        /// 会话配置
        /// </summary>
        public SessionSettings Session { get; set; } = new();

        /// <summary>
        /// 密码重置设置
        /// </summary>
        public PasswordResetSettings PasswordReset { get; set; } = new();
    }

    /// <summary>
    /// JWT配置
    /// </summary>
    public class JwtSettings
    {
        /// <summary>
        /// 密钥
        /// </summary>
        public string SecretKey { get; set; } = "";

        /// <summary>
        /// 发行者
        /// </summary>
        public string Issuer { get; set; } = "";

        /// <summary>
        /// 接收者
        /// </summary>
        public string Audience { get; set; } = "";

        /// <summary>
        /// 过期时间(分钟)
        /// </summary>
        public int ExpirationMinutes { get; set; } = 120;

        /// <summary>
        /// 刷新令牌过期时间(天)
        /// </summary>
        public int RefreshTokenExpirationDays { get; set; } = 7;

        /// <summary>
        /// 是否验证发行者
        /// </summary>
        public bool ValidateIssuer { get; set; } = true;

        /// <summary>
        /// 是否验证接收者
        /// </summary>
        public bool ValidateAudience { get; set; } = true;

        /// <summary>
        /// 是否验证生命周期
        /// </summary>
        public bool ValidateLifetime { get; set; } = true;
    }

    /// <summary>
    /// 密码配置
    /// </summary>
    public class PasswordSettings
    {
        /// <summary>
        /// 最小长度
        /// </summary>
        public int MinLength { get; set; } = 6;

        /// <summary>
        /// 最大长度
        /// </summary>
        public int MaxLength { get; set; } = 16;

        /// <summary>
        /// 是否要求包含数字
        /// </summary>
        public bool RequireDigit { get; set; } = true;

        /// <summary>
        /// 是否要求包含小写字母
        /// </summary>
        public bool RequireLowercase { get; set; } = true;

        /// <summary>
        /// 是否要求包含大写字母
        /// </summary>
        public bool RequireUppercase { get; set; } = true;

        /// <summary>
        /// 是否要求包含特殊字符
        /// </summary>
        public bool RequireSpecialCharacter { get; set; } = true;

        /// <summary>
        /// 密码过期天数
        /// </summary>
        public int ExpirationDays { get; set; } = 90;

        /// <summary>
        /// 密码历史记录数
        /// </summary>
        public int HistoryCount { get; set; } = 5;
    }

    /// <summary>
    /// 会话配置
    /// </summary>
    public class SessionSettings
    {
        /// <summary>
        /// 会话超时时间(分钟)
        /// </summary>
        public int TimeoutMinutes { get; set; } = 30;

        /// <summary>
        /// 是否允许多端登录
        /// </summary>
        public bool AllowMultipleLogin { get; set; } = true;

        /// <summary>
        /// 是否启用滑动过期
        /// </summary>
        public bool EnableSlidingExpiration { get; set; } = true;

        /// <summary>
        /// 是否记住登录状态
        /// </summary>
        public bool RememberMe { get; set; } = false;

        /// <summary>
        /// 记住登录状态过期天数
        /// </summary>
        public int RememberMeExpirationDays { get; set; } = 7;
    }

    /// <summary>
    /// 密码重置设置
    /// </summary>
    public class PasswordResetSettings
    {
        /// <summary>
        /// 密码重置基础URL
        /// </summary>
        public string BaseUrl { get; set; }

        /// <summary>
        /// 密码重置令牌路径
        /// </summary>
        public string TokenPath { get; set; }

    }
}